import BaseApi from '../BaseApi';

const controller = "/favorable";

export default {

    saveBatch(condition) {
        let map = condition.map(x => {
            return {
                minimumAmount: x.minimumAmount * 100,
                maxAmount: x.maxAmount * 100,
                favorableAmount: x.favorableAmount * 100
            }
        });
        map = JSON.stringify(map);
        return this.requestPostForJson(controller, "/saveBatch", map);
    },
    list() {
        return this.requestGet(controller, "/list");
    },

    /*请求封装*/
    requestPost(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestPost(newUrl, condition);
    },
    requestPostForJson(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestPostForJson(newUrl, condition);
    },
    requestGet(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestGet(newUrl, condition);
    },

}
